<!DOCTYPE html><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta charset="utf-8">
<title>phpDocumentor » \ActiveRecord\Errors</title>
<meta name="author" content="Mike van Riel">
<meta name="description" content="">
<link href="../css/template.css" rel="stylesheet" media="all">
<script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script><script src="../js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script><script src="../js/jquery.mousewheel.min.js" type="text/javascript"></script><script src="../js/bootstrap.js" type="text/javascript"></script><script src="../js/template.js" type="text/javascript"></script><script src="../js/prettify/prettify.min.js" type="text/javascript"></script><link rel="shortcut icon" href="../img/favicon.ico">
<link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="../img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="../img/apple-touch-icon-114x114.png">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner"><div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><a class="brand" href="../index.html">phpDocumentor</a><div class="nav-collapse"><ul class="nav">
<li class="dropdown">
<a href="#api" class="dropdown-toggle" data-toggle="dropdown">
                                    API Documentation <b class="caret"></b></a><ul class="dropdown-menu">
<li><a>Packages</a></li>
<li><a href="../packages/ActiveRecord.html"><i class="icon-folder-open"></i> ActiveRecord</a></li>
<li><a href="../packages/Default.html"><i class="icon-folder-open"></i> Default</a></li>
</ul>
</li>
<li class="dropdown" id="charts-menu">
<a href="#charts" class="dropdown-toggle" data-toggle="dropdown">
                                    Charts <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="../graph_class.html"><i class="icon-list-alt"></i> Class hierarchy diagram</a></li></ul>
</li>
<li class="dropdown" id="reports-menu">
<a href="#reports" class="dropdown-toggle" data-toggle="dropdown">
                                    Reports <b class="caret"></b></a><ul class="dropdown-menu">
<li><a href="../errors.html"><i class="icon-remove-sign"></i> Errors 
                <span class="label label-info">310</span></a></li>
<li><a href="../markers.html"><i class="icon-map-marker"></i> Markers 
                <ul><li>todo 
                <span class="label label-info">5</span>
</li></ul></a></li>
<li><a href="../deprecated.html"><i class="icon-stop"></i> Deprecated elements 
                <span class="label label-info">3</span></a></li>
</ul>
</li>
</ul></div>
</div></div>
<div class="go_to_top"><a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a></div>
</div>
<div id="___" class="container">
<noscript><div class="alert alert-warning">
                            Javascript is disabled; several features are only available
                            if Javascript is enabled.
                        </div></noscript>
<div class="row">
<div class="span4">
<span class="btn-group visibility" data-toggle="buttons-checkbox"><button class="btn public active" title="Show public elements">Public</button><button class="btn protected" title="Show protected elements">Protected</button><button class="btn private" title="Show private elements">Private</button><button class="btn inherited active" title="Show inherited elements">Inherited</button></span><div class="btn-group view pull-right" data-toggle="buttons-radio">
<button class="btn details" title="Show descriptions and method names"><i class="icon-list"></i></button><button class="btn simple" title="Show only method names"><i class="icon-align-justify"></i></button>
</div>
<ul class="side-nav nav nav-list">
<li class="nav-header">
<i class="icon-custom icon-method"></i> Methods
                    <ul>
<li class="method public "><a href="#method___construct" title="__construct :: Constructs an {@link Errors} object."><span class="description">Constructs an {@link Errors} object.</span><pre>__construct()</pre></a></li>
<li class="method public "><a href="#method___get" title="__get :: Retrieve error messages for an attribute."><span class="description">Retrieve error messages for an attribute.</span><pre>__get()</pre></a></li>
<li class="method public "><a href="#method___toString" title="__toString :: Convert all error messages to a String."><span class="description">Convert all error messages to a String.</span><pre>__toString()</pre></a></li>
<li class="method public "><a href="#method_add" title="add :: Add an error message."><span class="description">Add an error message.</span><pre>add()</pre></a></li>
<li class="method public "><a href="#method_add_on_blank" title="add_on_blank :: Adds the error message only if the attribute value was null or an empty string."><span class="description">Adds the error message only if the attribute value was null or an empty string.</span><pre>add_on_blank()</pre></a></li>
<li class="method public "><a href="#method_add_on_empty" title="add_on_empty :: Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}."><span class="description">Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}.</span><pre>add_on_empty()</pre></a></li>
<li class="method public "><a href="#method_clear" title="clear :: Clears out all error messages."><span class="description">Clears out all error messages.</span><pre>clear()</pre></a></li>
<li class="method public "><a href="#method_clear_model" title="clear_model :: Nulls $model so we don't get pesky circular references."><span class="description">Nulls $model so we don't get pesky circular references.</span><pre>clear_model()</pre></a></li>
<li class="method public "><a href="#method_full_messages" title="full_messages :: Returns all the error messages as an array."><span class="description">Returns all the error messages as an array.</span><pre>full_messages()</pre></a></li>
<li class="method public "><a href="#method_getIterator" title="getIterator :: Returns an iterator to the error messages."><span class="description">Returns an iterator to the error messages.</span><pre>getIterator()</pre></a></li>
<li class="method public "><a href="#method_get_raw_errors" title="get_raw_errors :: Returns the internal errors object."><span class="description">Returns the internal errors object.</span><pre>get_raw_errors()</pre></a></li>
<li class="method public "><a href="#method_is_empty" title="is_empty :: Returns true if there are no error messages."><span class="description">Returns true if there are no error messages.</span><pre>is_empty()</pre></a></li>
<li class="method public "><a href="#method_is_invalid" title="is_invalid :: Returns true if the specified attribute had any error messages."><span class="description">Returns true if the specified attribute had any error messages.</span><pre>is_invalid()</pre></a></li>
<li class="method public "><a href="#method_on" title="on :: Returns the error message(s) for the specified attribute or null if none."><span class="description">Returns the error message(s) for the specified attribute or null if none.</span><pre>on()</pre></a></li>
<li class="method public "><a href="#method_size" title="size :: Returns the number of error messages there are."><span class="description">Returns the number of error messages there are.</span><pre>size()</pre></a></li>
<li class="method public "><a href="#method_to_array" title="to_array :: Returns all the error messages as an array, including error key."><span class="description">Returns all the error messages as an array, including error key.</span><pre>to_array()</pre></a></li>
</ul>
</li>
<li class="nav-header">
<i class="icon-custom icon-property"></i> Properties
                    <ul><li class="property public "><a href="#property_DEFAULT_ERROR_MESSAGES" title="$DEFAULT_ERROR_MESSAGES :: "><span class="description"></span><pre>$DEFAULT_ERROR_MESSAGES</pre></a></li></ul>
</li>
<li class="nav-header private">» Private
                    <ul>
<li class="property private "><a href="#property_errors" title="$errors :: "><span class="description"></span><pre>$errors</pre></a></li>
<li class="property private "><a href="#property_model" title="$model :: "><span class="description"></span><pre>$model</pre></a></li>
</ul>
</li>
</ul>
</div>
<div class="span8">
<a id="\ActiveRecord\Errors"></a><ul class="breadcrumb">
<li>
<a href="../index.html"><i class="icon-custom icon-class"></i></a><span class="divider">\</span>
</li>
<li><a href="../namespaces/ActiveRecord.html">ActiveRecord</a></li>
<li class="active">
<span class="divider">\</span><a href="../classes/ActiveRecord.Errors.html">Errors</a>
</li>
</ul>
<div class="element class">
<p class="short_description">Class that holds {@link Validations} errors.</p>
<div class="details">
<div class="long_description"></div>
<table class="table table-bordered"><tr>
<th>package</th>
<td><a href="../packages/ActiveRecord.html">ActiveRecord</a></td>
</tr></table>
<h3>
<i class="icon-custom icon-method"></i> Methods</h3>
<a id="method___construct"></a><div class="element clickable method public method___construct" data-toggle="collapse" data-target=".method___construct .collapse">
<h2>Constructs an {@link Errors} object.</h2>
<pre>__construct(\ActiveRecord\Model $model) : <a href="../classes/ActiveRecord.Errors.html">\ActiveRecord\Errors</a></pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$model</h4>
<code><a href="../classes/ActiveRecord.Model.html">\ActiveRecord\Model</a></code><p>The model the error is for</p></div>
<h3>Returns</h3>
<div class="subelement response"><code><a href="../classes/ActiveRecord.Errors.html">\ActiveRecord\Errors</a></code></div>
</div></div>
</div>
<a id="method___get"></a><div class="element clickable method public method___get" data-toggle="collapse" data-target=".method___get .collapse">
<h2>Retrieve error messages for an attribute.</h2>
<pre>__get(string $attribute) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$attribute</h4>
<code>string</code><p>Name of an attribute on the model</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>or null if there is no error.</div>
</div></div>
</div>
<a id="method___toString"></a><div class="element clickable method public method___toString" data-toggle="collapse" data-target=".method___toString .collapse">
<h2>Convert all error messages to a String.</h2>
<pre>__toString() : string</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p>This function is called implicitely if the object is casted to a string:</p>

<pre><code>echo $error;

# "Name can't be blank\nState is the wrong length (should be 2 chars)"
</code></pre></div>
<h3>Returns</h3>
<div class="subelement response"><code>string</code></div>
</div></div>
</div>
<a id="method_add"></a><div class="element clickable method public method_add" data-toggle="collapse" data-target=".method_add .collapse">
<h2>Add an error message.</h2>
<pre>add(string $attribute, string $msg) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$attribute</h4>
<code>string</code><p>Name of an attribute on the model</p></div>
<div class="subelement argument">
<h4>$msg</h4>
<code>string</code><p>The error message</p></div>
</div></div>
</div>
<a id="method_add_on_blank"></a><div class="element clickable method public method_add_on_blank" data-toggle="collapse" data-target=".method_add_on_blank .collapse">
<h2>Adds the error message only if the attribute value was null or an empty string.</h2>
<pre>add_on_blank(string $attribute, string $msg) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$attribute</h4>
<code>string</code><p>Name of an attribute on the model</p></div>
<div class="subelement argument">
<h4>$msg</h4>
<code>string</code><p>The error message</p></div>
</div></div>
</div>
<a id="method_add_on_empty"></a><div class="element clickable method public method_add_on_empty" data-toggle="collapse" data-target=".method_add_on_empty .collapse">
<h2>Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}.</h2>
<pre>add_on_empty(string $attribute, string $msg) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$attribute</h4>
<code>string</code><p>Name of an attribute on the model</p></div>
<div class="subelement argument">
<h4>$msg</h4>
<code>string</code><p>The error message</p></div>
</div></div>
</div>
<a id="method_clear"></a><div class="element clickable method public method_clear" data-toggle="collapse" data-target=".method_clear .collapse">
<h2>Clears out all error messages.</h2>
<pre>clear() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="method_clear_model"></a><div class="element clickable method public method_clear_model" data-toggle="collapse" data-target=".method_clear_model .collapse">
<h2>Nulls $model so we don't get pesky circular references.</h2>
<pre>clear_model() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"><p>$model is only needed during the
validation process and so can be safely cleared once that is done.</p></div></div></div>
</div>
<a id="method_full_messages"></a><div class="element clickable method public method_full_messages" data-toggle="collapse" data-target=".method_full_messages .collapse">
<h2>Returns all the error messages as an array.</h2>
<pre>full_messages() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><pre><code>$model->errors->full_messages();

# array(
#  "Name can't be blank",
#  "State is the wrong length (should be 2 chars)"
# )
</code></pre></div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<a id="method_getIterator"></a><div class="element clickable method public method_getIterator" data-toggle="collapse" data-target=".method_getIterator .collapse">
<h2>Returns an iterator to the error messages.</h2>
<pre>getIterator() : <a href="http://php.net/manual/en/class.arrayiterator.php">\ArrayIterator</a></pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><p>This will allow you to iterate over the <a href="Errors">Errors</a> object using foreach.</p>

<pre><code>foreach ($model->errors as $msg)
  echo "$msg\n";
</code></pre></div>
<h3>Returns</h3>
<div class="subelement response"><code><a href="http://php.net/manual/en/class.arrayiterator.php">\ArrayIterator</a></code></div>
</div></div>
</div>
<a id="method_get_raw_errors"></a><div class="element clickable method public method_get_raw_errors" data-toggle="collapse" data-target=".method_get_raw_errors .collapse">
<h2>Returns the internal errors object.</h2>
<pre>get_raw_errors() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"><pre><code>$model->errors->get_raw_errors();

# array(
#  "name" => array("can't be blank"),
#  "state" => array("is the wrong length (should be 2 chars)",
# )
</code></pre></div></div></div>
</div>
<a id="method_is_empty"></a><div class="element clickable method public method_is_empty" data-toggle="collapse" data-target=".method_is_empty .collapse">
<h2>Returns true if there are no error messages.</h2>
<pre>is_empty() : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Returns</h3>
<div class="subelement response"><code>boolean</code></div>
</div></div>
</div>
<a id="method_is_invalid"></a><div class="element clickable method public method_is_invalid" data-toggle="collapse" data-target=".method_is_invalid .collapse">
<h2>Returns true if the specified attribute had any error messages.</h2>
<pre>is_invalid(string $attribute) : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$attribute</h4>
<code>string</code><p>Name of an attribute on the model</p></div>
<h3>Returns</h3>
<div class="subelement response"><code>boolean</code></div>
</div></div>
</div>
<a id="method_on"></a><div class="element clickable method public method_on" data-toggle="collapse" data-target=".method_on .collapse">
<h2>Returns the error message(s) for the specified attribute or null if none.</h2>
<pre>on(string $attribute) : \ActiveRecord\string/array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$attribute</h4>
<code>string</code><p>Name of an attribute on the model</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>\ActiveRecord\string/array</code>Array of strings if several error occured on this attribute.</div>
</div></div>
</div>
<a id="method_size"></a><div class="element clickable method public method_size" data-toggle="collapse" data-target=".method_size .collapse">
<h2>Returns the number of error messages there are.</h2>
<pre>size() : int</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"></div>
<h3>Returns</h3>
<div class="subelement response"><code>int</code></div>
</div></div>
</div>
<a id="method_to_array"></a><div class="element clickable method public method_to_array" data-toggle="collapse" data-target=".method_to_array .collapse">
<h2>Returns all the error messages as an array, including error key.</h2>
<pre>to_array(array $closure) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<div class="long_description"><pre><code>$model->errors->errors();

# array(
#  "name" => array("Name can't be blank"),
#  "state" => array("State is the wrong length (should be 2 chars)")
# )
</code></pre></div>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$closure</h4>
<code>array</code><p>Closure to fetch the errors in some other format (optional)
                      This closure has the signature function($attribute, $message)
                      and is called for each available error message.</p>
</div>
<h3>Returns</h3>
<div class="subelement response"><code>array</code></div>
</div></div>
</div>
<h3>
<i class="icon-custom icon-property"></i> Properties</h3>
<a id="property_DEFAULT_ERROR_MESSAGES"> </a><div class="element clickable property public property_DEFAULT_ERROR_MESSAGES" data-toggle="collapse" data-target=".property_DEFAULT_ERROR_MESSAGES .collapse">
<h2></h2>
<pre>$DEFAULT_ERROR_MESSAGES </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_errors"> </a><div class="element clickable property private property_errors" data-toggle="collapse" data-target=".property_errors .collapse">
<h2></h2>
<pre>$errors </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
<a id="property_model"> </a><div class="element clickable property private property_model" data-toggle="collapse" data-target=".property_model .collapse">
<h2></h2>
<pre>$model </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><div class="long_description"></div></div></div>
</div>
</div>
</div>
</div>
</div>
<div class="row"><footer class="span12">
            Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
            Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a12</a> and<br>
            generated on 2013-06-08T13:56:19-04:30.<br></footer></div>
</div>
</body>
</html>
